const files = require.context('@/constant', true, /\.js$/)
const install = (Vue, vm) => {
	vm.$u.constant = {}
	files.keys().forEach(key => {
		const filePathArr = key.split('/')
		let fileName = filePathArr[filePathArr.length - 1].match(/(\S.*?)(?=.js)/g)
		vm.$u.constant[fileName] = {}
		const constants = files(key)
		for (let item in constants) {
			vm.$u.constant[fileName][item] = constants[item]
		}
	})
}

export default {
	install
}
